function fibonacci(n) {
  if (n <= 1) {
    return n;
  } else {
    return fibonacci(n - 1) + fibonacci(n - 2);
  }
}

function calculateFibonacci(n) {
  var result = fibonacci(n);
  postMessage(result);
}

onmessage = function (event) {
  var n = event.data;
  calculateFibonacci(n);
};
